package org.example.autosuggest;

import java.util.Collection;

public class SuggestWithExpr {

    public static void main(String[] args) {
        LexerAndParserFactory lexerAndParserfactory = new ReflectionLexerAndParserFactory(
                com.neuronbit.parser.ExprLexer.class, com.neuronbit.parser.ExprParser.class);
        /*
        无法推进到最后一个token x。
         */
//        Collection<String> suggestions = new AutoSuggester(lexerAndParserfactory, "var xuz = 1; x").suggestCompletions();
        /*
        这里将x识别为ID
         */
//        Collection<String> suggestions = new AutoSuggester(lexerAndParserfactory, "x").suggestCompletions();
        /*
         * 当我输入的是va时，va有可能是var，也有可能是一个variable或function的名称，所以，提示的内容应该是：var, (, +, -, *, /
         * 但是，目前看起来没有var，后面的5个是OK的
         */
        Collection<SuggestionItem> suggestions = new AutoSuggester(lexerAndParserfactory, "va").suggestCompletions();
        if (null != suggestions && !suggestions.isEmpty()) {
            System.out.println("suggestions are:");
            for (SuggestionItem suggestion : suggestions) {
                System.out.println(suggestion);
            }
        } else {
            System.out.println("suggestion is empty");
        }
    }
}
